package com.xiangmu.controler;


import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xiangmu.mappers.RenyuanMapper;
import com.xiangmu.pojo.Renyuan;
import com.xiangmu.util.JsonResult;

@RestController
public class RenyuanControler extends BaseController
{

	@Autowired
	private RenyuanMapper renyuanMapper;
	
	
	@RequestMapping("/renyuanAdd")
	public JsonResult<Void> renyuanAdd(@RequestBody Renyuan renyuan) 
	{
		if(renyuan.getFujian().equals(""))
		{
			renyuan.setFujian("/upload/nophoto.gif");
		}
		renyuanMapper.insert(renyuan);
        return new JsonResult<>(66);
		
    }
	
	
	@RequestMapping("/renyuanMana")
	public JsonResult<List> renyuanMana() 
	{
		List renyuanList=renyuanMapper.select("","");
		return new JsonResult<>(66,renyuanList);
		
    }
	
	@RequestMapping("/renyuanDel")
	public JsonResult<Void> renyuanDel(int id) 
	{
		renyuanMapper.delete(id);
		return new JsonResult<>(66);
    }
	
	
	@RequestMapping("/renyuanUpdate")
	public JsonResult<Void> update(@RequestBody Renyuan renyuan) 
	{
		renyuanMapper.update(renyuan);
		return new JsonResult<>(66);
    }
	
	
	@RequestMapping("/renyuanRes")
	public JsonResult<List> renyuanRes(String xingming,String dianhua) 
	{
		List renyuanList=renyuanMapper.select(xingming.trim(),dianhua.trim());
		return new JsonResult<>(66,renyuanList);
		
    }
	
	@RequestMapping("/renyuanAll")
	public JsonResult<List> renyuanAll(String biaoti) 
	{
		List renyuanList=renyuanMapper.select("","");
		return new JsonResult<>(66,renyuanList);
		
    }
	
	
	@RequestMapping("/renyuanDetailQian")
	public JsonResult<Renyuan> renyuanDetailQian(int id) 
	{
		Renyuan renyuan=renyuanMapper.findByid(id);
		return new JsonResult<>(66,renyuan);
		
    }
	
}
